<?php
namespace app\index\validate;

use think\Validate;

/**
 * 登录验证
 * Class Login
 * @package app\index\validate
 */
class Password extends Validate
{
    protected $rule = [
        'password' => 'require',
        'new_password' => 'require|password:1',
        'new_password2' => 'require|confirm:new_password',
    ];

    protected $message = [
        'password.require' => 'Please enter your old password',
        'new_password.require' => 'Please enter a new password',
        'new_password2.require' => 'Please enter the confirmed password',
        'new_password2.confirm' => 'Your new password and the confirmed password are different. Please enter your passwords again.',
    ];
    
    protected function password($value){
        if($value){
            $exp = "/^(?![^a-zA-Z]+$)(?!\D+$).{9,25}$/";  
            if(preg_match($exp,$value)){  
                return true;  
            }else{  
                return 'Password format error,please re-enter again';  
            }  
        }
    }
    
}